package com.llb666.shop.items.api.vo;

import com.llb666.shop.items.domain.entity.Category;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 最新商品VO.
 *
 * @author llb666
 */
@Data
public class NewItemsVo {
    /**
     * 根节点类目Id
     */
    private Integer rootCatId;
    /**
     * 根节点类目名称.
     */
    private String rootCatName;
    /**
     * 图标.
     */
    private String slogan;
    /**
     * 类目图片.
     */
    private String catImage;
    /**
     * 背景颜色.
     */
    private String bgColor;

    /**
     * 商品Vo.
     */
    private List<SimpleItemVo> simpleItemList;

    @Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
    public interface Converter {
        NewItemsVo.Converter INSTANCE = Mappers.getMapper(NewItemsVo.Converter.class);

        @Mappings({
                @Mapping(source = "id", target = "rootCatId"),
                @Mapping(source = "name", target = "rootCatName")
        })
        NewItemsVo do2Vo(Category category);

        List<NewItemsVo> do2VoList(List<Category> carouselList);

    }
}
